package com.reger.l2cache.pipeline.ops;

import java.util.List;

import org.springframework.data.redis.connection.RedisListCommands.Position;
import org.springframework.lang.Nullable;

public interface RedisListPipeline<K, M> extends RedisKeyPipeline<K> {

	@Nullable
	Long rPush(K key, @SuppressWarnings("unchecked") M... values);

	@Nullable
	Long lPush(K key, @SuppressWarnings("unchecked") M... values);

	@Nullable
	Long rPushX(K key, M value);

	@Nullable
	Long lPushX(K key, M value);

	@Nullable
	Long lLen(K key);

	@Nullable
	List<M> lRange(K key, long start, long end);

	void lTrim(K key, long start, long end);

	@Nullable
	M lIndex(K key, long index);

	@Nullable
	Long lInsert(K key, Position where, M pivot, M value);

	void lSet(K key, long index, M value);

	@Nullable
	Long lRem(K key, long count, M value);

	@Nullable
	M lPop(K key);

	@Nullable
	M rPop(K key);

	@Nullable
	List<M> bLPop(int timeout, @SuppressWarnings("unchecked") K... keys);

	@Nullable
	List<M> bRPop(int timeout, @SuppressWarnings("unchecked") K... keys);

	@Nullable
	M rPopLPush(K srcKey, K dstKey);

	@Nullable
	M bRPopLPush(int timeout, K srcKey, K dstKey);

	default RedisListPipeline<K, M> toListPl() {
		return this;
	}
}
